package com.digitalchina.lxnsy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.base.BaseAdapter;
import com.digitalchina.lxnsy.entity.PesticideVO;
import com.digitalchina.lxnsy.viewholder.SimilarPesticideHolder;

import java.util.List;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.adapter
 * 创建人：byd
 * 创建时间：2017/4/5 16:47
 * 修改备注：
 * ================================================
 */

public class SimilarPesticideAdapter extends BaseAdapter<SimilarPesticideHolder, PesticideVO> {

    public SimilarPesticideAdapter(Context context, List<PesticideVO> listData) {
        super(context, listData);
    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, ViewGroup parent) {
        return inflate(R.layout.item_pesticide_details_list, parent);
    }

    @Override
    public SimilarPesticideHolder buildHolder(View convertView) {
        SimilarPesticideHolder holder = new SimilarPesticideHolder();
        holder.title = (TextView) convertView.findViewById(R.id.item_pesticide_list_tv_title);
        holder.type = (TextView) convertView.findViewById(R.id.item_pesticide_list_tv_type);
        holder.controlObject = (TextView) convertView.findViewById(R.id.item_pesticide_list_tv_control_object);
        holder.manufacturer = (TextView) convertView.findViewById(R.id.item_pesticide_list_tv_manufacturer);
        return holder;
    }

    @Override
    public void bindViewData(SimilarPesticideHolder holder, PesticideVO pesticideVO, int position) {
        holder.title.setText(null == pesticideVO.getName() ? "" : pesticideVO.getName());
        holder.type.setText(String.format("类型：%s", null == pesticideVO.getPesticideType() ? "" : null == pesticideVO.getPesticideType().getName() ? "" : pesticideVO.getPesticideType().getName()));
        holder.controlObject.setText(String.format("防治对象：%s", null == pesticideVO.getPrevention() ? "" : pesticideVO.getPrevention()));
        holder.manufacturer.setText(String.format("厂商：%s", null == pesticideVO.getManufacturer() ? "" : pesticideVO.getManufacturer()));
    }
}
